<?php
header('Content-type:text/html;charset=utf8');
/**
 * xysc users Version1.0
 * ==================================
 * Copy 2016-2017
 * Web:www.xjh7.com
 * ==================================
 * Author:xjh
 * Date:2016-3-15
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="stylesheet"  href="<?php echo backweb_CSS_URL;?>index.css" />
<link rel="stylesheet"  href="<?php echo backweb_CSS_URL;?>common.css" />
<script type="text/javascript" src="<?php echo backweb_JS_URL;?>jquery.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script>
function centerWindow(url,name,width,height){
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2 - 50;	
	window.open(url, name, 'width='+width+',height='+height+',top='+top+',left='+left);
}

//上传
function upload(id){
	if(id < 5){
		div = document.getElementById('light');
		div.style.display='block';
		document.getElementById('fade').style.display='block';
		childs = div.childNodes;	
		for(i = 0;i < childs.length;i++){
			if(childs[i].nodeName.toUpperCase() == "IFRAME"){
			    childs[i].src="./index.php?r=backweb/goods/mulupload&label="+id;
			}
		}
	} 
}

//添加元素
function create(id){
	span  = document.createElement("span");
	span.id = "span"+id;
	span.style.display = "block";
	span.height = "22px";
	span.lineHeight = "22px";
	
	span.innerHTML = "<input class='input-text h20 mb5' type='text' name='pic_url[]' id='pic_url"+id+"'> <input type='button'  onClick='upload("+id+")' value='上传详细图'  class='ml20 h25 w80 bgcolorace7ff cu'  />";
	if(id < 5)
	return span;
	else
		return false;
}

function add_img(){
	div = document.getElementById('pics');
	nums = parseInt(document.getElementById('num').value,10);
	document.getElementById('num').value = nums+1;
	obj = create(nums);
	div.appendChild(obj);
}

function initPro() {
	 var option1 = '';
		 $.ajax({
			url:'./index.php?r=backweb/brand/search',
			type:'post',
			dataType:'json',
			success:function (jsonData){
				var noSel = $("#op:selected").text();
				$.each(jsonData, function(index, indexItems) { 
						if(noSel != indexItems.name)
					   option1 += "<option value="+indexItems.category_id+">"
					     + indexItems.name + "</option>";
					  });
				  	$("#cat").append(option1);
				  	$("#cat").bind("change", function() {
				   		selectCity(jsonData);
				  	})
			},     
			error:function (){
				alert("加载失败");
			}
	 });
	  
	 function selectCity(data) {
	  var option2 = '';

	  var selectedIndex = $("#cat :selected").text();
	  $("#bra").empty();
	  if($("#cat :selected").val() == -1){
	   $("#bra").append("<option value='-1' id=\"-1\">请选择品牌</option>");
	  }
		option2 +="<option value=\"-1\">所有品牌</option>";
	  $.each(data, function(index, indexItems) {
	   var proName = indexItems.name;
	   $.each(indexItems.items, function(index, indexItems) {
	    if (indexItems.parentNode != selectedIndex) {
	     return;
	    } else {
	     option2 += "<option  value=" + indexItems.brand_id + ">"
	       + indexItems.name + "</option>";
	    }
	   })
	  });
	  $("#bra").append(option2);
	 };
	};
	$(function() {
	 initPro();
	});

</script>
<style>

.info { display:none; position:absolute; width:40%; top:25%; left:30%; z-index:9999; background-color:#fff; }
.hide { display:none; width:100%; height: 100%; background:#ccc; position:absolute; top:0; left:0; z-index: 1; filter:Alpha(opacity=50); -moz-opacaity:0.5; opacity:0.5; }
</style>
</head>
<body>
		<div class="place" >
		<span>位置：</span>
			<ul class="placeul">
				<li><a href="#">首页</a></li>
				<li><a href="./index.php?r=backweb/goods/goodshow">商品列表</a></li>
				<li><a href="#">新增商品</a></li>
			</ul>
		</div>
		<table class="list_table mt10">
		
		<form action="./index.php?r=backweb/goods/updategoods&goods_id=<?php echo $info['goods_id'];?>" name="fm" method="post">
			  <tr>
				 <td class="td_center wh100">所属店铺：</td>
				 <td>
				 		<select name="store_id" class="select" >
				 		<?php foreach($store_info as $_v){?>
							<option value="<?php echo $_v['store_id'];?>" <?php if($store_id == $_v['store_id']) echo 'selected="selected"';?> ><?php echo $_v['store_name'];?></option>
							<?php }?>
						</select>
				 </td>		
			  </tr>
			  <tr>
				 <td class="td_center wh100">商品名称：</td>
				 <td>
				     <input type="text" name="goods_name" value="<?php echo $info['goods_name'];?>" class="input-text" />
				 </td>		
			  </tr>
			  
			  <tr>
				 <td class="td_center wh100">品牌简介：</td>
				 <td>
				     <textarea name="goods_info" class="input-text wh500" cols="25" rows="3" ><?php echo $info['goods_info'];?></textarea>
				 </td>		
			  </tr>	
			  <tr>
				 <td class="td_center wh100">商品价格：</td>
				 <td>
				     <input type="text" name="goods_price" value="<?php echo $info['goods_price'];?>" class="input-text" />
				 </td>		
			  </tr>
			  <tr>
				 <td class="td_center wh100">专柜价格：</td>
				 <td>
				     <input type="text" name="goods_zgprice" value="<?php echo $info['goods_zgprice'];?>"  class="input-text" />
				 </td>		
			  </tr>
			  <tr>
				 <td class="td_center wh100">特权价格：</td>
				 <td>
				     <input type="text" name="goods_tqprice" value="<?php echo $info['goods_tqprice'];?>"  class="input-text" />
				 </td>		
			  </tr>
			  <tr>
				 <td class="td_center wh100 ">促销信息：</td>
				 <td>
				     <input type="text" name="goods_salpro"  value="<?php echo $info['goods_salpro'];?>" class="input-text" style="width:220px" />
				 </td>		
			  </tr>
			  <tr>
				 <td class="td_center wh100">缩略图：</td>
				 <td>
				 	<input type="text" name="goods_thumbnail_url" value="<?php echo $info['goods_thumbnail_url'];?>" class="input-text " style="width:400px;"  readonly="readonly" /> 
					<input type="button" value="上传缩略图" name="up"  onclick="centerWindow('./index.php?r=backweb/goods/thumbnail','upfile','400','100')" class="ml20 h25 w80 bgcolorace7ff cu" style="border:1px solid #ccc;" />
					<img name="pic" style="display:none;" />  </td>	
			  </tr>
			   <tr >
				 <td class="td_center wh100" >商品详细图：(
				 		修改页面暂时无法实现新增功能)</td>
				 <td>
				 	 <div id="light" class="info">
				 	 <div style="background:#eee;"><a style="font-size:2em;"  href="javascript:void(0)" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'"> 关闭</a></div>
				 	 		<iframe src="./index.php?r=backweb/goods/mulupload"  width="100%" height="auto" scrolling="auto" frameborder="0"   style="clear:both;padding-top: 5px"></iframe>
				 	 </div>
				 	 <div id="fade" class="hide"></div>
				 	 <div id="pics" >
					 	 <span id="span0" >
						 	 <div>
						 	 <input class='input-text h20 mb5 w350'    type='text' name='picpic[]'  value="<?php echo $details_img['img0'];?>"  id='pic_url0' readonly="readonly" > 
						 	 <input type='button'  onClick='upload(0)' value='上传详细图'   class='ml20 h25 w80 bgcolorace7ff cu'  /> <br />
						 	 </div>
						 	  
						 	 <div>
						 	 <input class='input-text h20 mb5 w350' type='text' name='picpic[]'  value="<?php echo $details_img['img1']?>" id='pic_url1' readonly="readonly" > 
						 	 <input type='button'  onClick='upload(1)' value='上传详细图'  class='ml20 h25 w80 bgcolorace7ff cu'  /> <br />
						 	 </div>
						 	 
						 	 <div>
						 	 <input class='input-text h20 mb5 w350' w350 type='text' name='picpic[]'  value="<?php echo $details_img['img2']?>" id='pic_url2' readonly="readonly" >
						 	 <input type='button'  onClick='upload(2)' value='上传详细图'  class='ml20 h25 w80 bgcolorace7ff cu'  /> <br />
						 	  </div>
						 	  
						 	  <div>
						 	 <input class='input-text h20 mb5 w350' type='text' name='picpic[]'  value="<?php echo $details_img['img3']?>" id='pic_url3' readonly="readonly" > 
						 	 <input type='button'  onClick='upload(3)' value='上传详细图'  class='ml20 h25 w80 bgcolorace7ff cu'  /> <br />
						 	  </div>
						 	  
						 	 <div>
						 	 <input class='input-text h20 mb5 w350' type='text' name='picpic[]'  value="<?php echo $details_img['img4']?>" id='pic_url4' readonly="readonly" > 
						 	 <input type='button'  onClick='upload(4)' value='上传详细图'  class='ml20 h25 w80 bgcolorace7ff cu'  />
						 	 </div>
						 	  
<!--	             		 <input type="button"  class="ml20 h20 w80 bgcolorace7ff cu"  value="再传一张"  onclick="add_img()" />-->
 						 </span>
					 </div>
						 <input type="hidden" id="num" name="num" value="1"  >
				</td>	
			  </tr>
			 
			  <tr>
			  <td class="td_center wh100">分类和品牌：</td>
				  <td>
				  		分类：
					    <select name="cat" class="select" id="cat">
							<option id="op"  <?php if($info['category_id'] == $catid) echo "selected='selected'";?> ><?php echo $catname;?></option>
						</select>
						品牌：
						<select name="brand" class="select"  id="bra">
					    	<?php foreach ($brainfo as $_k => $_vv){?>
							<option value="<?php echo $_k;?>"  <?php if($info['brand_id'] == $_k) echo "selected='selected'";?>><?php echo $_vv;?></option>
							<?php }?>
						</select>
					</td>
				</tr>
				<tr style="display: none">
					 <td class="td_center wh100">商品样式：</td>
					 <td>
					     <input type="text" name="goods_style" value="<?php echo $info['goods_style'];?>"  class="input-text w220"  />
					 </td>		
			  	</tr>
			  	<tr>
					 <td class="td_center wh100">生产日期：</td>
					 <td>
					     <input type="text" name="goods_birth" value="<?php echo $info['goods_birth'];?>"  class="input-text w220"  />( *产品生产日期)
					 </td>		
			  	</tr>
			  	<tr>
					 <td class="td_center wh100">关键词：</td>
					 <td>
					     <input type="text" name="goods_keyword" value="<?php echo $info['goods_keyword'];?>"  class="input-text w220"  />( *以逗号分割)
					 </td>		
			  	</tr>
			  	<tr>
					 <td class="td_center wh100">余量：</td>
					 <td>
					     <input type="text" name="goods_rest" value="<?php echo $info['goods_rest'];?>"  class="input-text w60"  />
					 已售：
					     <input type="text" name="goods_sell" value="<?php echo $info['goods_sell'];?>" class="input-text w60"  />
					 </td>		
			  	</tr>
				<tr>
					<td class="td_center wh100">商品详情：</td>
					<td><textarea id="TextArea1" name="goods_content"   class="ckeditor"><?php echo $info['goods_content'];?></textarea></td>
				</tr>
				<tr>
					 <td class="td_center wh100">生产商：</td>
					 <td>
					     <input type="text" name="goods_producer" value="<?php echo $info['goods_producer'];?>" class="input-text"  />
					 </td>		
			  	</tr>
			  	<tr>
					 <td class="td_center wh100">供应商：</td>
					 <td>
					     <input type="text" name="goods_supplier" value="<?php echo $info['goods_supplier'];?>" class="input-text"  />
					 </td>		
			  	</tr>
				 <tr>
					 <td class="td_center wh100">排序：</td>
					 <td>
						 <input type="text"  name="goods_sort"  value="<?php echo $info['goods_sort'];?>"  class="text sort" style="border:1px solid #ccc;width:40px;"/>
					 </td>		
			  	</tr>
				<tr>
					<td class="td_center wh100">是否上架：</td>
					<td> <input type="radio" name="onit" value="1" <?php if($info['onit'] == 1) echo "checked='checked'" ?>  <?php if(!$info['active'] && $user_type == '商家') echo 'disabled="disabled"'?>  />上架
					         <input type="radio" name="onit" value="0" <?php if($info['onit'] == 0) echo "checked='checked'" ?> <?php if(!$info['active'] && $user_type == '商家') echo 'disabled="disabled"'?>  />下架
					</td>
				</tr>
				<tr>
				  <td class="td_center">
				    <input type="submit" name="send" id="btsave" value="修改" class="btn btn82 btn_save ml25" />				
				 </td>
				 <td>
				   <input type="reset" value="重置" class="btn btn82 btn_res ml10" />
				</td>
			 </tr>
		</form>
			</table>
</body>
</html>